/*
Copyright (c) 2007, Arturo José Guédez Romero

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    * Neither the name of Cultusoft nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
*/


package com.cultusoft.groovin.script.command;

import com.cultusoft.groovin.plugins.build.Builder;
import com.cultusoft.groovin.plugins.build.Cycle
import com.cultusoft.groovin.plugins.build.Packager
import com.cultusoft.groovin.plugins.clean.Cleaner;
import com.cultusoft.groovin.plugins.deploy.Deployer;
import com.cultusoft.groovin.plugins.eclipse.Eclipse;
import com.cultusoft.groovin.plugins.tomcat.TomcatServerStarter
import com.cultusoft.groovin.plugins.tomcat.TomcatServerStopper
import com.cultusoft.groovin.plugins.selenium.SeleniumServerStarter
import com.cultusoft.groovin.plugins.selenium.SeleniumServerStopper
import com.cultusoft.groovin.plugins.fitnesse.FitnesseServerStarter
import com.cultusoft.groovin.plugins.fitnesse.FitnesseServerStopper
import com.cultusoft.groovin.plugins.fitnesse.FitnesseTestRunner
import com.cultusoft.groovin.plugins.fitnesse.FitServerRunner
import com.cultusoft.groovin.plugins.project.Tester


import com.cultusoft.groovin.script.command.AvailableCommands as commands

class CommandLoader {

    def configuration
    
    public void loadAllAvailableCommands() {
        def projects = configuration.getProjects()
        def repoDirectory = configuration.getRepoDirectory()
        def reportFolder = configuration.getReportFolder() 
        
        commands.addDefaultCommand("clean" , new Cleaner() )
        commands.addDefaultCommand("clean-all" , new Cleaner(projects:configuration.getProjects()))
        
        commands.addDefaultCommand("deploy", new Deployer())
        commands.addDefaultCommand("build", new Builder())
        commands.addDefaultCommand("package", new Packager())
        
        commands.addDefaultCommand("test", new Tester())
        commands.addDefaultCommand("test-all", new Tester(projects:configuration.getProjects()))

        commands.addGlobalCommand("cycle", new Cycle())
        
        commands.addGlobalCommand("start-fitnesse", new FitnesseServerStarter())
        commands.addGlobalCommand("fitServerTest", new FitServerRunner())
        commands.addGlobalCommand("stop-fitnesse", new FitnesseServerStopper())

        commands.addGlobalCommand("start-tomcat", new TomcatServerStarter())
        commands.addGlobalCommand("stop-tomcat", new TomcatServerStopper())

        commands.addGlobalCommand("start-selenium", new SeleniumServerStarter())
        commands.addGlobalCommand("stop-selenium", new SeleniumServerStopper())

        commands.addGlobalCommand("ftest-businessLayer", new FitnesseTestRunner(testToRun:"WorkoutLogger.ComponentValidation.SuiteBusinessLayer"))
        commands.addGlobalCommand("ftest-actionBeans", new FitnesseTestRunner(testToRun:"WorkoutLogger.ComponentValidation.SuiteStripesActionBeans"))
        commands.addGlobalCommand("ftest-uat", new FitnesseTestRunner(testToRun:"WorkoutLogger.ComponentValidation.SuiteWeb"))

        commands.addDefaultCommand("eclipse", new Eclipse())
        commands.addDefaultCommand("eclipse-all", new Eclipse(projects:configuration.getProjects()))
        
    
        /*commands.addLocalCommand("groovin", "clean", new Cleaner(repoDirectory:repoDirectory, projects:projects))
        commands.addLocalCommand("groovin", "build", new Builder())
        commands.addLocalCommand("groovin", "deploy", new Deployer(configuration:configuration))
        commands.addLocalCommand("groovin", "eclipse", new Eclipse(repoDirectory:repoDirectory, projects:projects))
        commands.addLocalCommand("groovin", "junit", new JUnitRunner(configuration:configuration))
        */
        
        
    }
}
